<?php
class  Module_CallCenter_YiChao_Call
{
    private static $obj = null;
    private $model = null;
    private $action = '/webAPI/webHttpAPI.php';

    private function __construct()
    {
        $this->model = new Lib_CallCenter_YiChao_Main();
    }

    public static function getInstance()
    {
        if (is_null(self::$obj)) {
            self::$obj = new self();
        }
        return self::$obj;
    }
    //外呼
    public function callOut($data){
        $request_data['exten'] = empty($data['workerId']) ? '' : $data['workerId'];
        $request_data['toTel'] = empty($data['toTel']) ? '' : $data['toTel'];
        if(!Lib_Notice::checkData($request_data,['exten','toTel'])) return Lib_Notice::response(4103);
        $request_data['model'] ='OnClickCallUniqueid';
        return $this->model->Grequest($this->action,$request_data);
    }
    //挂断
    public function hangUp($data){
        $request_data['agent'] = empty($data['workerId']) ? '' : $data['workerId'];
        if(!Lib_Notice::checkData($request_data,['agent'])) return Lib_Notice::response(4103);
        $request_data['model'] =__FUNCTION__;
        return $this->model->Grequest($this->action,$request_data);
    }
    //置忙
    public function setBuys($data){
        $request_data['agent'] = empty($data['workerId']) ? '' : $data['workerId'];
        if(!Lib_Notice::checkData($request_data,['agent'])) return Lib_Notice::response(4103);
        $request_data['model'] =__FUNCTION__;
        return $this->model->Grequest($this->action,$request_data);
    }
    //置闲
    public function setIdle($data){
        $request_data['agent'] = empty($data['workerId']) ? '' : $data['workerId'];
        if(!Lib_Notice::checkData($request_data,['agent'])) return Lib_Notice::response(4103);
        $request_data['model'] =__FUNCTION__;
        return $this->model->Grequest($this->action,$request_data);
    }
    //获取坐席状态
    public function getExtenStatus($data){
        if(!Lib_Notice::checkData($data,['agent'])) return Lib_Notice::response(4103);
        $data['model'] =__FUNCTION__;
        return $this->model->Grequest($this->action,$data);
    }
    //获取单条通话记录
    public function getRecodeByUID($data){
        if(!Lib_Notice::checkData($data,['uid','date'])) return Lib_Notice::response(4103);
        $data['model'] =__FUNCTION__;
        return $this->model->Grequest($this->action,$data);
    }
    //获取录音流
    public function getCallVoiceFile($data){
        if(!Lib_Notice::checkData($data,['uniqueid','userfield'])) return Lib_Notice::response(4103);
        $data['model'] =__FUNCTION__;
        return $this->model->Grequest($this->action,$data,20,1);
    }
    //获取录音流
    public function getList(){
        $data['model'] =__FUNCTION__;
        return $this->model->Grequest('/webAPI/MissCall.php',$data);
    }

}